<!--
 * @Date: 2020-09-21 09:02:51
 * @LastEditors: 小枫
 * @LastEditTime: 2020-09-21 13:32:38
 * @FilePath: \feng-blog-admin\src\views\CreateTags.vue
-->
<template lang="pug">
  .create-tag
    el-form
      el-form-item(label="分类名称")
        el-input.input(v-model="tag.tag")
      el-form-item( label="图片地址")
        el-input.input(v-model="tag.photoUrl")
      el-form-item
        el-button(@click="createTag", type="primary") 添加
</template>

<script>
export default {
  data () {
    return {
      tag: {
        tag: '',
        photoUrl: ''
      }
    }
  },
  methods: {
    // TODO: 图片应该上传自动对返回地址插入
    async createTag () {
      await this.$http.post('/tags', this.tag).then(
        res => {
          if (res) {
            this.$message({
              type: 'success',
              message: '添加成功'
            })
          }
        }
      )
      this.tag.tag = ''
      this.tag.photoUrl = ''
    }
  }
}
</script>

<style lang="less" scoped>
.create-tag {
  margin-top: 50px;
  text-align: left;
  .input {
    width: 70%;
  }
}
</style>
